package framework.system.entity;

import java.math.BigDecimal;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import framework.core.entity.BaseEntity;

/**
 * @ClassName: SysResource 
 * @Description: 系统资源配置类（包括菜单、按钮）
 * @author: Ching Wang
 * @date 2013-5-3 下午2:35:10 
 *
 */
@Entity
@Table(name = "sys_resource")
public class SysResource extends BaseEntity {

	/**
	 * 资源编号
	 */
	@Id
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid" ,strategy = "org.hibernate.id.UUIDGenerator")
	@Column(name = "id", nullable = false, length = 36)
	private String id;
	
	/**
	 * 上级资源
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pid")
	private SysResource sysResource;
	
	/**
	 * 资源名称
	 */
	@Column(name = "text", nullable = false, length = 100)
	private String text;
	
	/**
	 * 资源类型（菜单：menu  按钮：button）
	 */
	@Column(name = "type", nullable = false, length = 10)
	private String type;
	
	/**
	 * 资源方法
	 */
	@Column(name = "method", nullable = true, length = 50)
	private String method;
	
	/**
	 * 资源路径
	 */
	@Column(name = "url", nullable = true, length = 200)
	private String url;
	
	/**
	 * 资源图表
	 */
	@Column(name = "iconcls", nullable = true, length = 200)
	private String iconCls;
	
	/**
	 * 资源顺序
	 */
	@Column(name = "seq", precision = 22, scale = 0)
	private BigDecimal seq;
	
	/**
	 * 资源备注
	 */
	@Column(name = "remark", length = 4000)
	private String remark;
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sysResource")
	private Set<SysResource> sysResources;

	@ManyToMany(mappedBy = "sysResources", targetEntity = SysRole.class, cascade = CascadeType.MERGE)
	private Set<SysRole> sysRoles;

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the sysResource
	 */
	public SysResource getSysResource() {
		return sysResource;
	}

	/**
	 * @param sysResource the sysResource to set
	 */
	public void setSysResource(SysResource sysResource) {
		this.sysResource = sysResource;
	}

	/**
	 * @return the text
	 */
	public String getText() {
		return text;
	}

	/**
	 * @param text the text to set
	 */
	public void setText(String text) {
		this.text = text;
	}

	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @return the method
	 */
	public String getMethod() {
		return method;
	}

	/**
	 * @param method the method to set
	 */
	public void setMethod(String method) {
		this.method = method;
	}

	/**
	 * @return the url
	 */
	public String getUrl() {
		return url;
	}

	/**
	 * @param url the url to set
	 */
	public void setUrl(String url) {
		this.url = url;
	}

	/**
	 * @return the iconCls
	 */
	public String getIconCls() {
		return iconCls;
	}

	/**
	 * @param iconCls the iconCls to set
	 */
	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}

	/**
	 * @return the seq
	 */
	public BigDecimal getSeq() {
		return seq;
	}

	/**
	 * @param seq the seq to set
	 */
	public void setSeq(BigDecimal seq) {
		this.seq = seq;
	}

	/**
	 * @return the remark
	 */
	public String getRemark() {
		return remark;
	}

	/**
	 * @param remark the remark to set
	 */
	public void setRemark(String remark) {
		this.remark = remark;
	}

	/**
	 * @return the sysResources
	 */
	public Set<SysResource> getSysResources() {
		return sysResources;
	}

	/**
	 * @param sysResources the sysResources to set
	 */
	public void setSysResources(Set<SysResource> sysResources) {
		this.sysResources = sysResources;
	}

	/**
	 * @return the sysRoles
	 */
	public Set<SysRole> getSysRoles() {
		return sysRoles;
	}

	/**
	 * @param sysRoles the sysRoles to set
	 */
	public void setSysRoles(Set<SysRole> sysRoles) {
		this.sysRoles = sysRoles;
	}

}